package com.zyh.pool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/**
 * @Author zyh
 * @Date 2024/8/12 13:56
 * @Description newScheduledThreadPool 延时队列
 */

public class ThreadPoolDemo5 {
    public static void main(String[] args) {
        ScheduledExecutorService threadPool= Executors.newScheduledThreadPool(5);
        threadPool.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println(3);
            }
        });
        threadPool.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println(5);
            }
        });
        threadPool.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println(4);
            }
        });
        threadPool.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println(2);
            }
        });
        threadPool.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println(1);
            }
        });
        threadPool.shutdown();
    }
}
